import http from '@/api/http.js'
import global_config from "@/config.js"

export default async function(){
	let appRes, params, appData, appPower;
	params = {
		method: 'api/v2/system/app',
		mini_type: 1
	} 
	appRes = await http(params);
	if(appRes.status){
		appPower = {};
		appData = appRes.data.app;
		appData.map(item => {
			appPower[item] = true
		})
		uni.setStorageSync('getApplication', appPower);
		// 设置应用模块
		uni.setStorageSync('uniappModelData', appRes.data.models);
		// 设置可使用的产品模块
		let openProduct = global_config.openProduct;
		let typeids = [];
		appRes.data.product_type_id.map(item=> {
			if(openProduct.includes(item) || item> 199)
			{
				typeids.push(item);
			}
		});
		typeids = typeids.join(',');
		uni.setStorageSync('uniappProductTypeid', typeids);
		// 设置全局热搜词
		uni.setStorageSync('uniHotSearchDefault',appRes.data.hot_search_default)

		// 设置通用产品typeid
		uni.setStorageSync('uniTongYongTypeId',appRes.data.tongyong)
	}else{
		uni.showToast({
			title: appRes.msg,
			icon: "none"
		})
	}
}